<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.*" %>    
<%@page import="servlet.selectDeveloper"%>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Project's Property</title>
</head>
<%
	selectDeveloper sd=new selectDeveloper();
	ArrayList developerList=new ArrayList();
	developerList=sd.getDeveloperList();
%>
<body>
	<table>
		<tr>
 			<%@include file="Menu.jsp" %>
 		</tr>
	</table>
	
	<table>
		<form name=Property>
			<tr>
				<td>Select Developer</td>
				<td><select id="developer" onChange="showProjects()">
						<option value=-1>--Select--</option>
						<%
							for(int i=0;i<developerList.size();i++)
							{
						%>
						<option value='<%=developerList.get(i) %>'><%=developerList.get(i) %></option>
						<%	}		 %>
					</select>
			   </td>
			</tr>
			<tr>
				<td>Select Project</td>
				<td>
					<span id="loadProject">
						<select id="project">
							<option >--select--</option>
						</select>	
					</span>
				</td>
			</tr>
	
		</form>
	</table>
	
</body>

<script language='javascript'>

var xmlrequest=false;

function showProjects()
{
	
	xmlrequest=AjaxFunction();
	
	var url,selectindex,selectdeveloper;
	selectindex=document.getElementById("developer").selectedIndex;
	
	selectdeveloper=document.getElementById("developer").options[selectindex].text
	
	url="http://localhost:8181/PropertySite/getDevelopersProject";
	url=url+"?dName="+selectdeveloper;
	

	xmlrequest.open("GET",url,true);
	
	
	xmlrequest.onreadystatechange=function()
	{
		if(xmlrequest.readyState==4)
		 {
			if (xmlrequest.status==200)  
	         {  
				
	             document.getElementById("loadProject").innerHTML=xmlrequest.responseText;  
	         }  
		 }   
	    
	};
	
	xmlrequest.send(null); 
	
}

function AjaxFunction()
{
	try
	{	xmlrequest=new XMLHttpRequest(); 	}
	catch(e)
	{
		try{
			xmlrequest=new ActiveXObject("Msxml2.XMLHTTP");
		   }
		catch(e)
		   {
			   xmlrequest=new ActiveXObject("Microsoft.XMLHTTP");
		   }	   

	}
	return xmlrequest;	
}

</script>

</html>